home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
PC
/
MISCBAS
/
RADIX.ASC
< prev
next >
Wrap
Text File
|
1987-01-11
|
2KB
|
49 lines
1 'BASE-CONVERSIONS
2 'COPYRIGHT 1977 (C) BY W.A.BURTON - ALL RIGHTS RESERVED
3 PRINT CHR$(26) : PRINT "BASE CONVERSIONS" : PRINT
4 PRINT "ONLY INTEGER BASES IN RANGE OF 2-36 ARE VALID"
5 DIM R$(36), R1$(72), Y(72), L(72)
6 R$="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
7 PRINT "TO CHANGE BASES USED ENTER '---' WHEN PROMPTED WITH '?'"
8 INPUT "IN WHAT BASE WILL NUMBER(S) BE ENTERED ";R2
9 IF R2<>INT(R2) THEN 39
10 IF R2<2 THEN 41
11 IF R2>36 THEN 37
12 INPUT "TO WHAT BASE WILL NUMBER(S) BE CONVERTED ";R3
13 IF R3<>INT(R3) THEN 40
14 IF R3<2 THEN 42
15 IF R3>36 THEN 38
16 PRINT "INPUT YOUR NUMBER(S) WHEN PROMPTED WITH A '?'"
17 INPUT R1$
18 IF R1$="---" THEN 8
19 FOR L=1 TO LEN(R1$):FOR J=1 TO R2:IF MID$(R1$,L,1)=MID$(R$,J,1) THEN 22
20 NEXT J
21 PRINT "ENTRY ";R1$;" NOT LEGAL IN BASE ";R2 : GOTO 17
22 L(L)=J-1
23 NEXT L : Q1=LEN(R1$) : Q=0 : Q2=1
24 Y=0 : N=0
25 FOR L=Q2 TO Q1 : N=N*R2+L(L) : C=INT(N/R3) : N=N-R3*C
26 IF Y=0 THEN 29
27 Y=Y+1
28 L(Y)=C : GOTO 31
29 IF C=0 THEN 31
30 Y=1 : GOTO 28
31 NEXT L
32 Q=Q+1 : Y(Q)=N : Q1=Y : IF Y>0 THEN 24
33 PRINT TAB(20) R1$; " ";
34 FOR X1=POS(X+2) TO 38 : PRINT "-"; : NEXT
35 FOR L=Q TO 1 STEP -1 : G=Y(L)+1 : PRINT MID$(R$,G,1); : NEXT L
36 PRINT : GOTO 17
37 GOSUB 44 : GOTO 8
38 GOSUB 44 : GOTO 12
39 GOSUB 43 : GOTO 8
40 GOSUB 43 : GOTO 12
41 GOSUB 45 : GOTO 8
42 GOSUB 45 : GOTO 12
43 PRINT TAB(10) "INVALID ENTRY - MUST BE INTEGER !" : RETURN
44 PRINT TAB(10) "INVALID BASE - MUST BE <=36 !" : RETURN
45 PRINT TAB(10) "INVALID BASE - MUST BE >=2 !" : RETURN
: RETURN
44 PRINT TAB(10) "INVALID BASE - MUST BE <=36 !" : RETURN
45 PRINT TAB(10) "INVALID